use std::str::FromStr;
pub fn convert_base(num_str: &str, to_base: u32) -> String {
    //切分字符串读出原数字和其进制
    let (p,q)=num_str.rsplit_once('(').unwrap();
    let jin=u64::from_str(q.get(0..q.len()-1).unwrap()).unwrap();
    let mut sum=0;let mut z=1;
    for i in p.as_bytes().iter().rev(){
        sum+=u64::from(
                  //将单个字符还原成数字
            if i< &58  { *i-'0' as u8 }
                  else { *i-'a' as u8+10 }
            )*z;
        z=z*jin;
    }
    //创建输出字符串数组
    let mut out:[u8;20]=[0;20];
    z=0;
    //使用连除法，从后向前填充输出字符串
    for i in out.iter_mut().rev(){
        *i= sum as u8 % to_base as u8;
        *i=if *i<10{*i+'0' as u8 }
        else{*i+'a' as u8-10};
        sum=sum/to_base as u64;
        z+=1;
        if sum==0{
            break;

        }
    }
    //考虑为0的情况直接返回0
    if z>0{
        //裁剪字符串
        return String::from_utf8(out.get(20-z as usize..).unwrap().to_vec()).unwrap()

    }
    "0".to_string()
}
